<?php

namespace App\Http\Requests;

use Illuminate\Validation\Rule;

class UsersForm extends BaseFrom
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $validator = [
            'name'  => 'required',
            'email' => [
                'required',
                Rule::unique('users')->ignore($this->id)
            ],
        ];

        return $validator;
    }

    public function messages()
    {
        return [
            'name.required'  => '用户名必填',
            'email.required' => '邮箱必填',
            'email.unique'   => '该邮箱已注册过了',
        ];
    }
}
